package com.springaop.aspect;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Slf4j
@Component
public class AspectDemo1 {
    @Pointcut("execution(* com.springaop.controller.*.*(..))")
    public void pt(){}


@SneakyThrows
@Around("pt()")
    public Object recordTime(ProceedingJoinPoint pjp){
    log.info("目标方法执行前");
    Object result=pjp.proceed();
    log.info("目标方法执行后");
    return result;
}

@Before("pt()")
    public void doBefore(){
    log.info("doBefore");
}
    @After("pt()")
    public void doAfter(){
        log.info("doAfter");
    }
    @AfterReturning ("pt()")
    public void doAfterReturning(){
        log.info("doAfterReturning");
    }
    @AfterThrowing ("pt()")
    public void doAfterThrowing (){
        log.info("doAfterThrowing ");
    }


}
